<div style="text-align: center; color: red;line-height: 42px;font-size: 14px;background-color: rgba(255,255,255,0.4);font-weight:600;border-bottom:2px solid red;">
    设置取款密码
</div>

<div class="password-item" style="margin-top: 10px;">
    <input type="password" class="am-form-field old" placeholder="输入旧取款密码" />
</div>

<div class="password-item">
    <input type="password" class="am-form-field p1" placeholder="输入新取款密码" />
</div>

<div class="password-item">
    <input type="password" class="am-form-field p2" placeholder="再次输入新密码" />
</div>

<button class="button button-block button-positive button-disable" type="submit">提交</button>

<style type="text/css">
    .password-item {
        margin: 2px 15px 0px 15px;
    }
    .password-item input {
        line-height: 34px;
        border: 1px solid rgba(0,0,0,0.35);
        color: #000;
        border-radius: 2px;
        background-color: rgba(0,0,0,0.1);
        color: #000;
        font-size: 14px;
        padding: 0px 8px 0px 8px;
    }
    .button-block {
        margin-top: 10px;
    }

    input::-webkit-input-placeholder {
        color: rgba(255,255,255,0.5);
    }
　　input:-moz-placeholder {
        color: rgba(255,255,255,0.5);
    }
　　input::-moz-placeholder {
        color: rgba(255,255,255,0.5);
    }
　　input:-ms-input-placeholder { 
        color: rgba(255,255,255,0.5);
    }
</style>

<script>
    $("#center-top .home").hide();
    $("#center-top .back").show();
    $("#center-top .menu").hide();

    var _checkEnable = function() {
        var old = $(".old").val().trim(),
            p1 = $(".p1").val().trim(),
            p2 = $(".p2").val().trim();
        if (old == '') {
            return false;
        }
        if (p1 == '') {
            return false;
        }
        if (p2 == '') {
            return false;
        }
        return true;
    }
    $("input").bind('input propertychange', function() {
        if (_checkEnable()) $(".button-block").removeClass("button-disable");
        else $(".button-block").addClass("button-disable");
    });
    
    $(".button-block").click(function() {
        var old = $(".old").val().trim(),
            p1 = $(".p1").val().trim(),
            p2 = $(".p2").val().trim();
        if (old == '' && context.user.user.tpassword) {
            alert2("请输入旧密码！");
            return;
        }
        if (p1 == '') {
            alert2("请输入新密码！");
            return;
        }
        if (p2 == '') {
            alert2('请再次输入新密码！');
            return;
        }
        if (p1 != p2) {
            alert2("两次密码不匹配，请重新输入！");
            return;
        }
        if (context.user.user.tpassword && old != context.user.user.tpassword) {
            alert2("旧的取款密码错误！");
            return;
        }

        startLoading();
        CMD.modify_user_info(undefined, { tpassword: p1 } , function() {
            context.user.user.tpassword = p1;
            stopLoading();
            alert2("密码修改成功！");
            setTimeout(function() {
                Util.jumpUrl({
                    cmd: 'index'
                });
            }, 1500);
        }, function(message) {
            stopLoading();
            alert2(message || '密码修改失败！');
        });
    });
</script>